#ifndef THREADS_COMMON_H_
#define THREADS_COMMON_H_

#include <stdio.h>
#include <stdlib.h>

volatile hs_int32_t tx_thread1to2_flag1;
volatile hs_int32_t tx_thread2to3_flag1;
volatile hs_int32_t tx_data_flag2;
volatile hs_int32_t tx_data_flag3;

//total = 15bits used in SYNC register
#define TX_RX_MODE_2_BIT_1 0
#define TX_RX_MODE_2_BIT_2 1
#define TX_RX_MODE_3_BIT_1 2
#define TX_RX_MODE_3_BIT_2 3
#define THREAD13_FLAG_BIT  4
#define THREAD12_FLAG_BIT  5
#define THREAD23_FLAG_BIT  6
#define THREAD3ALLRATE_FLAG_BIT 7
#define THREAD3EQINDEX_FLAG_BIT 8
#define THREAD12_SINCOS_FLAG_BIT 9
#define THREAD21_SINCOS_FLAG_BIT 10
#define TX_THREAD12_FLAG_BIT 11
#define TX_THREAD23_FLAG_BIT 12
#define TX_DATA_FLAG2_BIT 13
#define TX_DATA_FLAG3_BIT 14

#define SET_SYNC_BIT(bit) (__sb_ctsr(1<<bit,MACH_SYNC1))
#define UNSET_SYNC_BIT(bit) (__sb_ctsr(1<<bit,MACH_SYNC0))
#define SET_SYNC_(value) (__sb_ctsr(value,MACH_SYNC1))
#define UNSET_SYNC_(value) (__sb_ctsr(value,MACH_SYNC0))

#define GET_SYNCBIT(bit) ((__sb_ctsr(MACH_SYNC0)>>bit) & 0x1)
#define GET_SYNC() (__sb_ctsr(MACH_SYNC0))

extern volatile hs_int32_t tx_rx_mode_2;
extern volatile hs_int32_t tx_rx_mode_3;
extern volatile hs_int32_t tx_rx_mode_4;

extern volatile hs_int32_t phy_rx_tx_dacinit_flag;

#endif /*THREADS_COMMON_H_*/
